//
//  MTRootToolBarViewController.m
//  YuchBox
//
//  Created by Ivan on 11-11-2.
//  Copyright 2011年 __MyCompanyName__. All rights reserved.
//

#import "MTRootToolBarViewController.h"
#import "LayoutParam.h"
#import "SingletonClassGenerator.h"

@implementation MTRootToolBarViewController
//@synthesize navigationController = _navigationController;
@synthesize ivanTabBar           = _ivanTabBar;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
//        self.view.frame = CGRectMake(0, 0, 320, 480);
    }
    return self;
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView
{
}
*/


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
    [super viewDidLoad];
    [DataSource checkRunTimeEnvironment];

//    self.navigationController.navigationBar.barStyle = UIBarStyleDefault;
    self.navigationController.navigationBar.tintColor = [UIColor colorWithRed:186.0/255.0 green:186.0/255.0 blue:186.0/255.0 alpha:1.0];

    // init mainview
    MTEmailViewController *controller1 = [[MTEmailViewController alloc] init];
    NSMutableDictionary *controllerDict1 = [[NSMutableDictionary alloc] initWithObjectsAndKeys:@"tarbar_message1.png", @"image", controller1, @"viewController", nil];
    [controller1 release];
    // init msgview
    MTMainViewController *controller2 = [[MTMainViewController alloc] initWithNibName:@"MTMainViewController" bundle:nil];
    NSMutableDictionary *controllerDict2 = [[NSMutableDictionary alloc] initWithObjectsAndKeys:@"tarbar_reserve.png", @"image", controller2, @"viewController", nil];
    [controller2 release];
    
    MTMsgViewController *controller3 = [[MTMsgViewController alloc] initWithNibName:@"MTMsgViewController" bundle:nil];
    NSMutableDictionary *controllerDict3 = [[NSMutableDictionary alloc] initWithObjectsAndKeys:@"tarbar_reserve1.png", @"image", controller3, @"viewController", nil];
    [controller3 release];
    
    MTEmptyViewController *controller4 = [[MTEmptyViewController alloc] initWithNibName:@"MTEmptyViewController" bundle:nil];
    NSMutableDictionary *controllerDict4 = [[NSMutableDictionary alloc] initWithObjectsAndKeys:@"tarbar_reserve2.png", @"image", controller4, @"viewController", nil];
    [controller4 release];
    
    MTEmptyViewController *controller5 = [[MTEmptyViewController alloc] initWithNibName:@"MTEmptyViewController" bundle:nil];
    NSMutableDictionary *controllerDict5 = [[NSMutableDictionary alloc] initWithObjectsAndKeys:@"tarbar_more.png", @"image", controller5, @"viewController", nil];
    [controller5 release];
    
    NSMutableArray *controllerArray = [[NSMutableArray alloc] initWithObjects:controllerDict1,controllerDict2,controllerDict3,controllerDict4,controllerDict5, nil];
    
    [controllerDict1 release];
    [controllerDict2 release];
    [controllerDict3 release];
    [controllerDict4 release];
    [controllerDict5 release];
    // self.ivanTabBar.items = controllerArray;
    
    _ivanTabBar = [[IvanTabBar alloc] initWithItemCount:[controllerArray count] 
                                                  Items:controllerArray 
                                 BackgroudImageFileName:@"spring_background.png" 
                                        AutoSizeByImage:NO 
                                                barFrame:CGRectMake(TOOLBAR_X, TOOLBAR_Y, TOOLBAR_WIDTH, TOOLBAR_HEIGHT)
                                     ArrowImageFileName:@"tarbar_arrow.png"
                                               Delegate:self];
    [controllerArray release];
    
    [self.view addSubview:_ivanTabBar];
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end
